package com.thexu.sqlSession;

import com.thexu.config.XMLConfigBuilder;
import com.thexu.pojo.Configuration;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

public class SqlSessionFactoryBuilder {
    public SqlSessionFactory build(InputStream in) throws DocumentException, PropertyVetoException {
        //解析配置文件封装到configuration对象中
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder();
        Configuration configuration = xmlConfigBuilder.parseConfig(in);
        //创建SqlSessionFactory对象
        return new DefaultSqlSessionFactory(configuration);
    }
}
